import request from "@/api/request";
import {
  ADD_NEW_FRIEND_APPLY_API,
  GET_UID_BY_QQ,
  GET_GROUP_BY_GROUP_NUMBER_API,
  ADD_FRIEND_API,
  ADD_GROUP_MEMBER_API
} from "@/api/api_constant";

export const addFriend = async (myId,friendId) => {
  return await request.put(ADD_FRIEND_API,{
    myId,
    friendId
  })
}

export const addGroupMember = async (fromId,groupId) => {
  return await request.post(ADD_GROUP_MEMBER_API,{
    fromId,
    groupId
  })
}

export const addFriendApply = async (
  from_id,
  to_id,
  type,
  from_name,
  from_avatar,
  group_id
) => {
  return await request.post(ADD_NEW_FRIEND_APPLY_API, {
    from_id,
    to_id,
    type,
    from_name,
    from_avatar,
    group_id
  });
};

export const getGroupIdByNumber = async (group_number) => {
  return await request.get(GET_GROUP_BY_GROUP_NUMBER_API, {
    params: {
      group_number,
    },
  });
}

export const getUserIdByQq = async (qq_account) => {
  return await request.get(GET_UID_BY_QQ, {
    params: {
      qq_account,
    },
  });
};
